home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / BostonBusinessComputing / bbc / dist / tssunxfltr < prev    next >
Text File  |  2000-02-11  |  2KB  |  72 lines

  1. sed    -e 's/\/\(.*\)\/\([^\/]*\)$/\[\1\]\2/' \
  2.     -e 's/^\/\(.*\)/\[000000]\1/' \
  3.       -e 's/\//\./g' |
  4. awk 'BEGIN { ORS=" "
  5.          maxcol = '`getcol - `'
  6.          colsize = 20
  7.          d = int(maxcol)/int(colsize)
  8.          fcount = 0
  9.          dcount = 0
  10.          tfcount = 0        
  11.          }
  12.     {fname = 1}            # Filename is first field
  13.     /^$/        { break }
  14.     /^Directory/    {
  15.               if (dcount != 0 ) {
  16.                         if ( fcount == 1 )
  17.                     printf "\n\nTotal of %d file.\n", fcount
  18.                         else if ( fcount >= 1 )
  19.                     printf "\n\nTotal of %d files.\n", fcount, dcount
  20.                   }
  21.               dcount = dcount + 1
  22.               tfcount = tfcount + fcount
  23.               fcount = 0
  24.               colnum = 0
  25.               printf "\n%s\n\n", $0
  26.               continue
  27.               }
  28.     /^[0-9][0-9]* file[s]* in [0-9][0-9]* dir/{ continue }
  29.     $2 ~ /^d/    { $fname = $fname ".dir" }
  30.     $2 ~ /^l/    {            # Any sym. links?
  31.         for ( count=1; count <= NF; count++)
  32.             if ($count == "->")
  33.             {
  34.             fname = count - 1    # Filespec. precedes sym. link
  35.             break
  36.             }
  37.         }
  38.     { n = split($fname, fspec, "/")
  39.     if ( fspec[n] !~ '/[\.]/' )
  40.         fspec[n] = fspec[n] "."
  41.     fcount = fcount + 1
  42.     if ( int(colnum) > int(d))
  43.     {
  44.         printf "\n"
  45.         colnum = 1
  46.     }
  47.     takes = length(fspec[n])/colsize + 1
  48.     if ( int(takes) + int(colnum) > int(d))
  49.     {
  50.         printf "\n"
  51.         colnum = takes
  52.     }
  53.     else
  54.         colnum+= int(takes)
  55.     fmt = "%-" int(takes) * int(colsize) "s"
  56.     printf fmt, fspec[n] }        # Print filename
  57.     END {
  58.           if (fcount == 0 && tfcount == 0)
  59.          printf "%%DIRECTORY-W-NOFILES, no files found. \n"
  60.           else { tfcount = tfcount + fcount
  61.              if ( fcount == 1 )
  62.              printf "\n\nTotal of %d file.\n", fcount
  63.                   else if ( fcount >= 1 )
  64.               printf "\n\nTotal of %d files\n", fcount, dcount
  65.                if (dcount > 1)
  66.                   if (tfcount > 1)
  67.                  printf "\nGrand total of %d directories, %d files.\n", dcount,tfcount
  68.                   else
  69.                  printf "\nGrand total of %d directories, %d file.\n", dcount,tfcount
  70.             }
  71.          }'
  72.